package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ecable.bean.PackagesTO;
import com.ecable.bean.ProfileTO;
import com.ecable.daoImpl.PackagesDaoImpl;
import com.ecable.util.UtilConstants;

public class ViewPackagesAction extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String path = "";
		RequestDispatcher rd = null;

		Vector<PackagesTO> vpack = new Vector<PackagesTO>();
		try {
			vpack = new PackagesDaoImpl().viewPackage();
		} catch (Exception le) {
			request.setAttribute("status", UtilConstants._INVALID_PACKAGE);
			rd = request
					.getRequestDispatcher(UtilConstants._ADD_PACKAGE_FAILED);
		}

		if (!vpack.isEmpty()) {

			request.setAttribute("status", UtilConstants._PACKAGE_VIEW_SUCCESS);
			request.setAttribute("packinfo", vpack);
			path = UtilConstants._VIEW_PACKAGE;

		} else {

			request.setAttribute("status", UtilConstants._ADD_PACKAGE_FAILED);
			path = UtilConstants._VIEW_PACKAGE;

		}

		rd = request.getRequestDispatcher(path);

		rd.forward(request, response);
	}

}